The present invention relates to a router serving as an inter-LAN connection apparatus for connecting a plurality of LANs (Local Area Networks) and, more particularly, to a router for high-speed packet communication between terminal apparatuses in different LANs.
As is known, a LAN is used as a communication network for communication between terminal apparatuses in a relatively small-size range such as one company or a limited area.
As a technique of expanding such a network, a technique of connecting different LANs by using inter-LAN connection apparatuses called routers is used.
A router is designed to perform network interconnection by converting the lower three layers of a total of seven layers of a reference OSI (Open System Interconnection) model, i.e., the three layers including the network layer and the subsequent layers. This router updates and outputs the data link layer address of a received packet so as to sequentially cause the address to approach the destination of the packet mainly on the basis of the destination address of the network layer of the received packet. Routing is performed in this manner.
The following description is based on the assumption that an IP (Internet Protocol) is used on the network layer. In addition, addresses on the network layer and the data link layer will be respectively referred to as an IP address and a media access control (MAC) address.
FIG. 7 shows a communication network in which a plurality of LANs 1 to 4 are connected to each other through conventional routers 10 and 10'.
In this case, network addresses are assigned to the LANs 1 to 4 in advance to identify the respective networks.
IP addresses are assigned to terminal apparatuses 1a, . . . 2a, . . . , 3a, . . . , 4a, . . . in the LANs 1 to 4 to identify the respective terminal apparatuses in accordance with the network addresses of the LANs to which the terminal apparatuses belong.
Each terminal apparatus has a unique MAC address (generally having a six-octet length) registered in the apparatus manufacturing process.
Similar to the terminal apparatuses, IP addresses are assigned to the interfaces of the routers 10 and 10' connected to the LANs 1 to 4 in correspondence with the network addresses of the LANs to which the interfaces are directly connected. In addition, MAC addresses are registered in units of interfaces.
Each of the routers 10 and 10' includes two types of memory tables, i.e., a routing table and an ARP (address resolution protocol) table, to obtain an optimal route through which a packet received from a terminal apparatus in a LAN and addressed to a terminal apparatus in another LAN is to be transmitted to the destination LAN.
FIGS. 8A and 8B respectively show a routing table 11 and an ARP table 12 of the router 10.
In the "DESTINATION" column of the routing table 11 in FIG. 8A, the network addresses of the LANs 1 to 4 which the router 10 can connect are stored.
In the "GATEWAY" column, data "(0.0.0.0)" are stored to indicate that there are no gateways for LANs, of the LANs whose addresses are stored in the "DESTINATION" column, which are directly connected to the router 10, like the LANs 1 to 3.
In the "GATEWAY" column, IP address [20.0.0.2] of the interface of another router 10' with respect to the LAN 2 is stored in correspondence with the LAN 4 which is indirectly connected to the LAN 2 through the router 10'.
In the "NET MASK" column, net mask data (4-octet length) are stored. Each of net mask data is used as a mask value when comparing the destination IP address of the received packet with the "DESTINATION" column of the routing table.
In the "METRIC" column, information about the distance to the LAN to which a terminal apparatus which is to receive a packet belongs (generally the number of routers interposed between the router and the LAN) is stored.
In the "INTERFACE" column, interface numbers indicating the specific interfaces to be used for connection to the respective LANs are stored.
In the ARP table 12 in FIG. 8B, the IP addresses and MAC addresses of the terminal apparatuses in the LANs 1 to 3 directly connected to the router 10 and the interface of another router 10', on the LAN 2 side, which is directly connected to the LAN 2, are stored in correspondence with each other.
Note that the router 10' also includes two types of memory tables similar to those described above.
FIG. 9 is a flow chart showing a procedure for routing performed by the router 10.
For example, an operation to be performed when a packet is to be transmitted from the terminal apparatus 1a in the LAN 1 to the terminal apparatus 4a in the LAN 4 will be described below with reference to the flow chart of FIG. 9.
First of all, the terminal apparatus 1a transmits a packet P1 in FIG. 10A onto the LAN 1.
This packet P1 has a MAC header portion Ha, an IP header portion Hb, and data portions Da and FCS (Frame Check Sequence).
In the MAC header portion Ha, the MAC address (R.sub.11) of the router 10 to which the packet is directly transmitted is written as a destination MAC address DA.sub.MAC (to be simply referred to as DA.sub.MAC hereinafter), and the MAC address (T.sub.11) of the terminal apparatus la itself is also written as a source MAC address SA.sub.MAC (to be simply referred to as SA.sub.MAC hereinafter).
In the IP header portion Hb, IP address [10.0.0.5] of the terminal apparatus la itself is written as a source IP address SA.sub.IP (to be simply referred to as SA.sub.IP hereinafter), and IP address [192.168.21.5] of the terminal apparatus 4a which is to finally receive the packet P1 is written as a destination IP address DA.sub.IP (to be simply referred to as DA.sub.IP hereinafter).
As shown in FIG. 9, the router 10 receives the packet P1, in which the MAC address (R.sub.11) of its interface is written as DA.sub.MAC, on the LAN 1, and calculates the AND of DA.sub.IP [192.168.21.5] of the packet P1 and each net mask data of the routing table 11. The router 10 then obtains the AND which coincides the network address in the corresponding row of the "DESTINATION" column (steps S1 to S4).
According to the above table, network address [192.168.21.0] is uniquely determined by the AND of DA.sub.IP and net mask data [255.255.255.0] ("255" is 8-bit data consisting of only 1s; "0" is 8-bit data consisting of only 0s) in the fourth row of the table when viewed from the top.
If the ANDs coincide with a plurality of network addresses in the ANDs calculation in step 1 to 4, the router 10 obtains one of the network addresses which has the smallest metric value (steps S5 and S6).
The router 10 then checks the presence/absence of a gateway address corresponding to this network address (step S7).
In this case, since [20.0.0.2] is present as a gateway address, the router 10 reads out the MAC address (R.sub.21) corresponding to the gateway address from the ARP table 12 (step S8).
If the gateway address corresponding to the obtained network address is (0.0.0.0), the router 10 reads out the MAC address corresponding to DA.sub.IP of the packet received on the LAN 1 from the ARP table 12 (step S9).
As shown in FIG. 10B, the router 10 updates DA.sub.MAC with the obtained MAC address (R.sub.21), and outputs a packet P2 whose SA.sub.MAC is updated with the MAC address (R.sub.13) of the interface of the router 10 itself, which is connected to the LAN 2, from the previously obtained interface to the LAN 2 (step S10).
Routing processing similar to the routing processing performed by the router 10 is also performed by the router 10'.
More specifically, the router 10' receives the packet P2 on the LAN 2, and calculates the AND of DA.sub.IP [192.168.21.5] of the packet P2 and each mask data of the routing table of the router 10'. With this operation, the router 10' obtains network address [192.168.21.0] of the LAN 4 to which the terminal apparatus 4a belongs, and also obtains the interface to which the LAN 4 is connected. In addition, the router 10' reads out the MAC address (T.sub.41) corresponding to DA.sub.IP [192.168.21.5] from the ARP table, and outputs a packet P3 whose MAC header portion Ha is updated with the readout MAC address (T.sub.41) and the MAC address (R.sub.22) of the router 10' to the LAN 4, as shown in FIG. 10C.
The terminal apparatus 4a connected to the LAN 4 receives the packet P3 in which the MAC address (T.sub.41) of the apparatus itself is written as DA.sub.MAC of the MAC header portion.
In this manner, with routing performed by the routers 10 and 10', packets can be reliably exchanged between terminal apparatuses in different LANs.
Note that the IP address of an interface itself may be stored in the "GATEWAY" row of the routing table, instead of (0.0.0.0), to indicate the direct connection of the interface.
In the above conventional router, however, the two types of memory tables (the routing table 11 and the ARP table 12) are referred to twice every time a packet is received, and the routing table 11 is searched for an optimal route in consideration of net mask data and metric values. That is, complicated processing is required. For this reason, software processing is inevitably required, and hence high-speed routing processing cannot be realized.
Although a considerable increase in the data transmission rate in each LAN has recently been attained, the routing speed cannot be increased because the above complicated processing is performed by means of software every time a packet is received. The efficiency of packet transmission to other LANs is therefore very low.
In addition to the scheme of connecting remote LANs to each other, a scheme has recently been realized, in which a plurality of terminal apparatuses connected to the connectors of one switching hub are formed into a plurality of groups to realize VLANs (virtual LANs) in units of groups.
The routers for connecting such VLANs to each other, however, cannot perform high-speed packet transmission even between terminal apparatuses in different VLANs which are located at a short distance from each other.